Printing Groups on New Pages and Resetting Page Count
Introduction
This example illustrates a situation where it is desired to print each group on a new page and to reset the page number to 1 for each group. The COUNTER and RESETEXPR functions will be utilized to accomplish this.
Example 1 showed how to reset the SUM and COUNT functions after printing (by selecting the “Reset after print” check box). For this example the PAGENUMBER function seemingly could be used to print the page number, however this function cannot be reset. Instead the COUNTER function is used to count pages since this function can be reset using the RESETEXPR function when required.
The Employees, Orders, Order_Details, and Products tables within the sample database are used within this example. The report will list all sales orders per employee as shown below:
Note that the page numbers increment for each employee, but reset to 1 for the next employee.
The following describes the format of the report.
- The Title Band contains the text string “Employee Sales”.
- The Column Header Band contains the Sale Date, Quantity, and Product Name Headers.
- The Group Header Band contains the employee last name and first name. It also contains the function RESETEXPR.
- The Detail Band contains the sale date, quantity, and product name.
- The Page Footer Band contains the COUNTER function which represents the page number.
Force Group Header on new page
To force the Group Header to print on a new page, double-click on the Group Header to launch the Group Header options dialog. On the dialog, check the option to “Force new page (before)”.
The report design above shows a COUNTER function in the Page Footer band. Every time the band prints (once per page), the counter increments.
Reset the COUNTER expression
The name of the COUNTER expression must be obtained such that it can be reset within the RESETEXPR function. To obtain the name, right-click on the [‘Page ‘ + COUNTER] expression then click “Options’ to obtain the Expression Name, which in this case is Expression1.
To force the page counter to reset for each group, the RESETEXPR function must contain the expression to reset (the COUNTER expression) when this band (Group Header) is printed. Therefore ’Expression1’ is entered as the parameter as shown in the figure below. The expression name must be enclosed within single quotes.